package com.zrj.gulimall.controller;

import com.zrj.common.es.SkuEsModel;
import com.zrj.common.utils.R;
import com.zrj.gulimall.service.ElasticSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhaorujie
 * @version 1.0
 * @Description
 * @date 2021/1/30 12:51
 */
@RequestMapping("/search/save")
@RestController
public class ElasticSaveController {

    @Autowired
    private ElasticSaveService elasticSaveService;

    /**
     * 上架商品
     * @param skuEsModels
     * @return
     */
    @PostMapping(value = "/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels){

        boolean status = false;
        try {
            status = elasticSaveService.productStatusUp(skuEsModels);
        }catch (Exception e){
            e.printStackTrace();
        }
        return R.ok().setData(status);
    }
}
